<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let arr = []
    while(arr.length < 6){
      let num = +prompt(`请输入第${arr.length+1}个人有效年龄`)
      if( num > 0 && num < 100){
        arr.push(num)
    }
    console.log(arr);
    }
    for (let i = 0; i < arr.length; i++) {
      if (arr[i] >= 18) {
        document.write(`已经成人的年龄是: ${arr[i]} <br>`)
      }
    }
    let sum = 0
    for (let i = 0; i < arr.length; i++) {
      sum += arr[i]
    }
    document.write(`所有人的年龄是: ${sum} <br>`)
    let average = 0
    average = sum / arr.length
    document.write(`所有人的年龄是: ${average} <br>`)
    let max = arr[0]
    let min = arr[0]
    for (let i = 1; i < arr.length; i++) {
      if (max < arr[i]) {
        max = arr[i]
      }
      if (min > arr[i]) {
        min = arr[i]
      }
    }
    document.write(`最大值是: ${max} <br>`)
    document.write(`最小值是: ${min} <br>`)
    arr.sort(function (a, b) {
      return a - b;
    }) 
    
  </script>
</body>
</html>